﻿(function($) {

    function calendarWidget(el, params) {

        var now = new Date();
        var thismonth = now.getMonth();
        var thisyear = now.getYear() + 1900;

        var opts = {
            month: thisyear + "-" + thismonth
        };

        $.extend(opts, params);

        var calendar = $(bee.frag['calendarFrag']).attr("id", "").attr("class", "calendar").show().click(function(event) {
            event.stopPropagation();
        });
        calendar.find(".head").hide();
        calendar.find(".foot").hide();

        calendar.find(".dayNames").html(dayNames);

        var dayNames = "";
        $.each($.regional.datepicker.dayNames, function(i, v) {
            dayNames += "<dt>" + v + "</dt>"
        });

        var monthStart = new Date(opts.year, opts.month - 1, 1);
        debugger;
        var dayStr = calendar.getDayStr(opts.month);

        var $days = calendar.find(".days").html(dayStr).find("dd");
        $days.find(".other").addClass("disabled");

        $days.click(function() { alert("test") });

        $(el).html(calendar);
    }

    // jQuery plugin initialisation
    $.fn.calendarWidget = function(params) {
        calendarWidget(this, params);
        return this;
    };

})(jQuery);